'use strict';

const db = uniCloud.database();
const collection = db.collection('medicine');
exports.main = async (event, context) => {
	const {
		familyId,
		categoryId
	} = event;
	const res = await collection.where({
		familyId,
		categoryId
	}).get();
	// 如果还没有药品，则返回空数组
	if (res.data.length === 0) {
		return {
			code: 0,
			data: []
		};
	}

	//返回数据给客户端
	return {
		code: 0,
		data: res.data
	};
};